package com.example.moneybook.controller;

import com.example.moneybook.dto.RepaymentDto;
import com.example.moneybook.dto.ResponseResult;
import com.example.moneybook.pojo.Borrow;
import com.example.moneybook.service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 包
 * @Date: 2023/3/1 13:14
 * Description:
 */
@RestController
@RequestMapping("/borrow")
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    @PostMapping("/addborrow")
    public ResponseResult addBorrow(@RequestBody Borrow borrow, @RequestParam(name = "accountName") String accountName){
        return borrowService.addBorrow(borrow, accountName);
    }

    @PostMapping("/loadborrowbill")
    public ResponseResult loadBorrowBill(@RequestParam(name = "userId") String userId, @RequestParam(name = "state") int state){
        return borrowService.loadBorrowBill(userId, state);
    }

    @PostMapping("/repayment")
    public ResponseResult repayment(@RequestBody RepaymentDto repaymentDto){
        return borrowService.repayment(repaymentDto);
    }

}
